.class public Lcom/glympse/android/glympse/DlgAvatarPicker;
.super Lcom/glympse/android/glympse/DlgList;
.source "DlgAvatarPicker.java"

# interfaces
.implements Lcom/glympse/platform/common/GlympseListener;
.implements Landroid/widget/AdapterView$OnItemClickListener;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSource;,
        Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSourceAdapter;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Lcom/glympse/android/glympse/DlgList;",
        "Lcom/glympse/platform/common/GlympseListener;",
        "Landroid/widget/AdapterView$OnItemClickListener;"
    }
.end annotation


# static fields
.field private static final AVATAR_CAMERA:I = 0x0

.field private static final AVATAR_GALLERY:I = 0x1


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "oContext"

    .prologue
    .line 42
    const/4 v0, 0x0

    invoke-direct {p0, p1, v0}, Lcom/glympse/android/glympse/DlgList;-><init>(Landroid/content/Context;Ljava/lang/String;)V

    .line 43
    return-void
.end method

.method private onClickCamera()V
    .locals 4

    .prologue
    .line 127
    :try_start_0
    sget-object v1, Lcom/glympse/android/glympse/Glympse;->ms_oThis:Lcom/glympse/android/glympse/Glympse;

    new-instance v2, Landroid/content/Intent;

    const-string v3, "android.media.action.IMAGE_CAPTURE"

    invoke-direct {v2, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    const/4 v3, 0x1

    invoke-virtual {v1, v2, v3}, Lcom/glympse/android/glympse/Glympse;->startActivityForResult(Landroid/content/Intent;I)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 133
    :goto_0
    return-void

    .line 129
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 131
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method private onClickGallery()V
    .locals 4

    .prologue
    .line 140
    :try_start_0
    new-instance v1, Landroid/content/Intent;

    const-string v2, "android.intent.action.PICK"

    invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 141
    .local v1, oIntent:Landroid/content/Intent;
    sget-object v2, Landroid/provider/MediaStore$Images$Media;->EXTERNAL_CONTENT_URI:Landroid/net/Uri;

    const-string v3, "vnd.android.cursor.dir/image"

    invoke-virtual {v1, v2, v3}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 142
    sget-object v2, Lcom/glympse/android/glympse/Glympse;->ms_oThis:Lcom/glympse/android/glympse/Glympse;

    const/4 v3, 0x2

    invoke-virtual {v2, v1, v3}, Lcom/glympse/android/glympse/Glympse;->startActivityForResult(Landroid/content/Intent;I)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 148
    .end local v1           #oIntent:Landroid/content/Intent;
    :goto_0
    return-void

    .line 144
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 146
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method


# virtual methods
.method public DoUpdate(I)V
    .locals 1
    .parameter "nUpdateFlags"

    .prologue
    .line 80
    and-int/lit16 v0, p1, 0x2000

    if-eqz v0, :cond_0

    .line 82
    invoke-virtual {p0}, Lcom/glympse/android/glympse/DlgAvatarPicker;->UpdateIconAndTitle()V

    .line 84
    :cond_0
    return-void
.end method

.method protected UpdateIconAndTitle()V
    .locals 3

    .prologue
    .line 105
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v2

    iget-object v2, v2, Lcom/glympse/platform/Platform;->m_oUserList:Lcom/glympse/platform/common/UserList;

    invoke-virtual {v2}, Lcom/glympse/platform/common/UserList;->GetSelf()Lcom/glympse/platform/common/User;

    move-result-object v1

    .line 106
    .local v1, oUser:Lcom/glympse/platform/common/User;
    if-eqz v1, :cond_0

    iget-object v2, v1, Lcom/glympse/platform/common/User;->m_oImageAvatar:Lcom/glympse/platform/GImage;

    if-eqz v2, :cond_0

    iget-object v2, v1, Lcom/glympse/platform/common/User;->m_oImageAvatar:Lcom/glympse/platform/GImage;

    iget-object v2, v2, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    if-eqz v2, :cond_0

    const/4 v2, 0x1

    move v0, v2

    .line 109
    .local v0, fHasAvatar:Z
    :goto_0
    if-eqz v0, :cond_1

    .line 111
    iget-object v2, v1, Lcom/glympse/platform/common/User;->m_oImageAvatar:Lcom/glympse/platform/GImage;

    iget-object v2, v2, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    invoke-virtual {p0, v2}, Lcom/glympse/android/glympse/DlgAvatarPicker;->SetTitleIcon(Landroid/graphics/drawable/Drawable;)V

    .line 119
    :goto_1
    if-eqz v0, :cond_2

    const v2, 0x7f0a007b

    :goto_2
    invoke-virtual {p0, v2}, Lcom/glympse/android/glympse/DlgAvatarPicker;->SetTitleText(I)V

    .line 120
    return-void

    .line 106
    .end local v0           #fHasAvatar:Z
    :cond_0
    const/4 v2, 0x0

    move v0, v2

    goto :goto_0

    .line 115
    .restart local v0       #fHasAvatar:Z
    :cond_1
    const v2, 0x7f0200bc

    invoke-virtual {p0, v2}, Lcom/glympse/android/glympse/DlgAvatarPicker;->SetTitleIcon(I)V

    goto :goto_1

    .line 119
    :cond_2
    const v2, 0x7f0a007a

    goto :goto_2
.end method

.method protected onCreate(Landroid/os/Bundle;)V
    .locals 6
    .parameter "savedInstanceState"

    .prologue
    .line 48
    invoke-virtual {p0}, Lcom/glympse/android/glympse/DlgAvatarPicker;->getContext()Landroid/content/Context;

    move-result-object v2

    .line 51
    .local v2, oContext:Landroid/content/Context;
    invoke-virtual {p0}, Lcom/glympse/android/glympse/DlgAvatarPicker;->UpdateIconAndTitle()V

    .line 54
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    .line 55
    .local v0, listAvatarSources:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSource;>;"
    new-instance v3, Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSource;

    const v4, 0x7f0a0053

    invoke-virtual {v2, v4}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v4

    const v5, 0x7f02000a

    invoke-direct {v3, v4, v5}, Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSource;-><init>(Ljava/lang/String;I)V

    invoke-virtual {v0, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 56
    new-instance v3, Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSource;

    const v4, 0x7f0a0054

    invoke-virtual {v2, v4}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v4

    const v5, 0x7f02000b

    invoke-direct {v3, v4, v5}, Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSource;-><init>(Ljava/lang/String;I)V

    invoke-virtual {v0, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 59
    new-instance v1, Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSourceAdapter;

    invoke-virtual {p0}, Lcom/glympse/android/glympse/DlgAvatarPicker;->getContext()Landroid/content/Context;

    move-result-object v3

    invoke-direct {v1, p0, v3, v0}, Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSourceAdapter;-><init>(Lcom/glympse/android/glympse/DlgAvatarPicker;Landroid/content/Context;Ljava/util/ArrayList;)V

    .line 60
    .local v1, oAvatarAdapter:Lcom/glympse/android/glympse/DlgAvatarPicker$AvatarSourceAdapter;
    const/4 v3, 0x1

    invoke-virtual {p0, v1, p0, v3}, Lcom/glympse/android/glympse/DlgAvatarPicker;->SetListAdapter(Landroid/widget/ListAdapter;Landroid/widget/AdapterView$OnItemClickListener;Z)Landroid/widget/ListView;

    .line 63
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v3

    invoke-virtual {v3, p0}, Lcom/glympse/platform/Platform;->AddGlympseListener(Lcom/glympse/platform/common/GlympseListener;)V

    .line 65
    invoke-super {p0, p1}, Lcom/glympse/android/glympse/DlgList;->onCreate(Landroid/os/Bundle;)V

    .line 66
    return-void
.end method

.method protected onDestroy()V
    .locals 1

    .prologue
    .line 72
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v0

    invoke-virtual {v0, p0}, Lcom/glympse/platform/Platform;->RemoveGlympseListener(Lcom/glympse/platform/common/GlympseListener;)V

    .line 74
    invoke-super {p0}, Lcom/glympse/android/glympse/DlgList;->onDestroy()V

    .line 75
    return-void
.end method

.method public onItemClick(Landroid/widget/AdapterView;Landroid/view/View;IJ)V
    .locals 0
    .parameter
    .parameter "oView"
    .parameter "nPos"
    .parameter "lRow"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/widget/AdapterView",
            "<*>;",
            "Landroid/view/View;",
            "IJ)V"
        }
    .end annotation

    .prologue
    .line 89
    .local p1, oAdapterView:Landroid/widget/AdapterView;,"Landroid/widget/AdapterView<*>;"
    packed-switch p3, :pswitch_data_0

    .line 99
    :goto_0
    return-void

    .line 92
    :pswitch_0
    invoke-direct {p0}, Lcom/glympse/android/glympse/DlgAvatarPicker;->onClickCamera()V

    goto :goto_0

    .line 96
    :pswitch_1
    invoke-direct {p0}, Lcom/glympse/android/glympse/DlgAvatarPicker;->onClickGallery()V

    goto :goto_0

    .line 89
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_1
    .end packed-switch
.end method
